{extend name="template/base" /}
{block name="nav"}{/block}
{block name="content"}
<div class="page-container">
    <form class="form form-horizontal" id="form" method="post" action="{:\\think\\Request::instance()->baseUrl()}">
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">所属菜单：</label>
            <div class="formControls col-xs-3 col-sm-3">
                <div class="select-box">
                    <select name="pid" class="select" id="pid">
                        <option value="0">顶级菜单</option>
                        {notempty name="top_menu"}
                            {volist name='top_menu' id='vo'}
                            <option value="{$key}">{$vo}</option>
                            {/volist}
                        {/notempty}
                    </select>
                </div>
            </div>
            <div class="formControls col-xs-3 col-sm-3" id="second_area"></div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>菜单名称：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" value="" placeholder="" name="name" datatype="*" nullmsg="菜单名称不能为空" />
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">图标：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" value="" placeholder="不填写默认为列表图标" name="icon">
            </div>
            <div class="col-xs-3 col-sm-3">当第二个select为--请选择--时，请尽量填写此项</div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"></label>
            <div class="formControls col-xs-6 col-sm-6">
                小图标请到<a class="c-blue" href="http://h-ui.net/Hui-3.7-Hui-iconfont.shtml" target="_blank" rel="nofollow">http://h-ui.net/Hui-3.7-Hui-iconfont.shtml</a>复制tab标签为阿里巴巴Iconfont下的icon文字，如
                <span class="label label-success f-16">{:htmlspecialchars('&#xf0005;')}</span>
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">菜单链接：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" value="" placeholder="模型/控制器/方法" name="menu_url" />
            </div>
            <div class="col-xs-3 col-sm-3">顶级菜单和二级菜单此项留空，模型/控制器/方法</div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">类型：</label>
            <div class="formControls col-xs-3 col-sm-3">
                <div class="select-box">
                    <select name="type" class="select">
                        {volist name="$Think.config.conf.menu_type" id="vo"}
                            <option value="{$key}">{$vo}</option>
                        {/volist}
                    </select>
                </div>
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>状态：</label>
            <div class="formControls col-xs-6 col-sm-6 skin-minimal">
                <div class="radio-box">
                    <input type="radio" name="status" id="status-1" value="1" datatype="*" nullmsg="请选择状态" />
                    <label for="status-1">启用</label>
                </div>
                <div class="radio-box">
                    <input type="radio" name="status" id="status-0" value="0" />
                    <label for="status-0">禁用</label>
                </div>
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">排序：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" value="1000" placeholder="" name="order_no" />
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <button type="submit" class="btn btn-primary radius">&nbsp;&nbsp;提交&nbsp;&nbsp;</button>
                <button type="button" class="btn btn-default radius ml-20" onClick="layer_close();">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
            </div>
        </div>
    </form>
</div>
{/block}
{block name="script"}
<script type="text/javascript" src="__LIB__/Validform/5.3.2/Validform.min.js"></script>
<script>
    $(function () {
        $("[name='status'][value='1']").attr("checked",true);

        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });

        $("#form").Validform({
            tiptype:2,
            ajaxPost:true,
            showAllError:true,
            callback:function(ret){
                ajax_progress(ret);
            }
        });
        //获取二级菜单
        $('#pid').on('change',function(){
            var pid = $(this).val();
            if(pid == undefined || pid == ''){
                return false;
            }
            $.post("/admin/Menu/ajaxSecondMenu",{'pid':pid},function(ret){
                //console.log(ret);
                if(ret.code == 200){
                    //成功
                    $("#second_area").html(ret.data);
                }else{
                    //失败
                    alert(ret.data);
                }
            },"json");
        });
    });
</script>
{/block}